<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<lv-form [lvLabelColon]="false" class="resource-summary" lvLayout="vertical">
  <lv-form-column style="height:100%" *ngFor="let column of formItems; index as i" [ngClass]="{'summary-container': i === 0}">
    <table style="height:100%" class="summary-icon" [ngClass]="{ 'summary-info-border': i !== 0 }">
      <tr>
        <td>
          <div style="width: 48px;height: 48px;">
            <i lv-icon="aui-icon-summary-host" *ngIf="
                i === 0 && [resourceType.FusionComputeCNA.value, resourceType.cNwareHost.value, resourceType.nutanixHost.value, resourceType.hyperVHost.value].includes(sourceType)
              "></i>
            <i lv-icon="aui-sla-fc-cluster" *ngIf="
                i === 0 && [resourceType.FusionComputeCluster.value, resourceType.cNwareCluster.value, resourceType.nutanixCluster.value].includes(sourceType)
              "></i>
            <i lv-icon="aui-icon-hcs-project" *ngIf="
                i === 0 && (resourceType.Project.value === sourceType || resourceType.stackProject.value === sourceType || resourceType.ApsaraStack.value === sourceType)
              "></i>
            <i lv-icon="aui-icon-summary-sla" *ngIf="i === 1"></i>
          </div>
        </td>
        <td class="summary-info">
          <lv-form-item *ngFor="let item of column">
            <lv-form-label class="summary-info-label">{{item.label}}</lv-form-label>
            <lv-form-control class="summary-info-item">
              <span lv-overflow  class="name-overflow" *ngIf="
                  'link_status' !== item.key &&
                  'sla_policy' !== item.key &&
                  'sla_compliance' !== item.key &&
                  'protect_activation' !== item.key
                ">
                {{ item.content | nil }}
              </span>
              <span *ngIf="'link_status' === item.key">
                <ng-container *ngIf="
                    [
                     resourceType.FusionComputeCluster.value,
                      resourceType.FusionComputeCNA.value
                    ].includes(sourceType)
                  ">
                  <aui-status [value]="item.content" type="Database_Resource_LinkStatus"></aui-status>
                </ng-container>
                <ng-container *ngIf="[resourceType.cNwareHost.value].includes(sourceType)">
                  <aui-status [value]="item.content" type="cnwareLinkStatus"></aui-status>
                </ng-container>
                <ng-container *ngIf="sourceType === resourceType.hyperVHost.value">
                  <aui-status [value]="item.content" type="resource_LinkStatus_Special"></aui-status>
                </ng-container>
                <ng-container *ngIf="sourceType === resourceType.nutanixHost.value">
                  <aui-status [value]="item.content" type="nutanixHostStatus"></aui-status>
                </ng-container>
              </span>
              <span *ngIf="'protect_activation' === item.key">
                <aui-status [value]="item.content" type="Protection_Status"></aui-status>
              </span>
              <span *ngIf="'sla_policy' === item.key">
                <ng-container *ngIf="item.content; else slaTemplate">
                  <span lv-overflow  class="sla-overflow">
                    <sla-type [name]="item.content"></sla-type>
                  </span>
                </ng-container>
                <ng-template #slaTemplate>
                  --
                </ng-template>
              </span>
              <span *ngIf="'sla_compliance' === item.key">
                <ng-container *ngIf="item.content || item.content === false; else emptyTpl">
                  <aui-status [value]="item.content" type="Sla_Compliance"></aui-status>
                </ng-container>
              </span>
            </lv-form-control>
          </lv-form-item>
        </td>
      </tr>
    </table>
  </lv-form-column>
</lv-form>

<ng-template #emptyTpl>
  --
</ng-template>
